﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CNFM_CROCODILE_LOGO.Core.Domain.ViewModels;
using CNFM_CROCODILE_LOGO.Services.Interfaces;
using CNFM_CROCODILE_LOGO_WebApi.OAuthManagement;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace CNFM_CROCODILE_LOGO_WebApi.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class UserController : ControllerBase
    {
        private IUserWXServices _pro;
        public UserController(IUserWXServices pro)
        {
            this._pro = pro;
        }

        //[HttpGet]
        //[Route("All")]
        //public IActionResult GetUserAll()
        //{
        //    var ret = _pro.GetUserAll();
        //    return Ok(ret);
        //}

        /// <summary>
        /// 登陆
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        [HttpPost("Login")]
        public IActionResult Login(UserModels user)
        {
            var ret = _pro.Login(user.LoginName, user.Password);
            return Ok(ret);
        }

        /// <summary>
        /// 企业详情
        /// </summary>
        /// <returns></returns>
        [HttpGet("GetEnterprise")]
        [Authorize("Permission")]
        public IActionResult GetEnterprise()
        {
            var ret = _pro.GetEnterprise();
            return Ok(ret);
        }

        /// <summary>
        /// 企业修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost("UpdateEnterprise")]
        [Authorize("Permission")]
        public IActionResult UpdateEnterprise(EnterpriseModels model)
        {
            var ret = _pro.UpdateEnterprise(model);
            return Ok(ret);
        }

    }
}